﻿create function [dbo].[func_GetChuyenBay]
(
	@SanBayDi varchar(10),
	@SanBayDen varchar(10),
	@ThoiGianBay datetime,
	@ThoiGianVe datetime
)
returns 
@DSChuyenBay table(MaChuyenBay int, LoaiChuyenBay int)
as
begin
	insert into @DSChuyenBay 
	select MaChuyenBay, 0 from dbo.ChuyenBay where SanBayDi = @SanBayDi and SanBayDen = @SanBayDen and DATEDIFF(day,ThoiGianDi,@ThoiGianBay) = 0
	insert into @DSChuyenBay 
	select MaChuyenBay, 1 from dbo.ChuyenBay where SanBayDi = @SanBayDen and SanBayDen = @SanBayDi and DATEDIFF(day,ThoiGianDi,@ThoiGianVe) = 0									
	return
end


